﻿using System;
using Interfaces.CommonData;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using StockInfoFacade;
using StockInfoDataLayer;

namespace TST_ALL
{
    [TestClass]
    public class TST_ViewModel
    {
        private readonly string _connString = @"Data Source=bigboy; Integrated Security=SSPI;";
        private readonly string _dbName = @"OakHill";

        [TestMethod]
        public void TST_RefreshDB()
        {
            StockInfoVM vm = new StockInfoVM(_connString, _dbName);

            vm.FromTo = new DateInterval() { DateFrom = DateTime.Today.AddYears(-5), DateTo = DateTime.Today };
            vm.RefreshDatabase(IndexName.SAndP100);
        }

        [TestMethod]
        public void TST_Correlation()
        {
            DBManager mgr = DBManager.CreateInstance(_connString, _dbName);
            StockTable stbl = new StockTable();

            List<Stock> lstStocks = stbl.GetIndexStocks();

            PriceTable ptbl = new PriceTable();
            List<StockPrice> lstPrices =  ptbl.GetAllPrices();

            StockInfoFacade.BusinessLogic.Correlation C = new StockInfoFacade.BusinessLogic.Correlation();
            Dictionary<Stock, Dictionary<Stock, Decimal>> 
                dCorr = C.ComputeMatrix(lstPrices, lstStocks);

            Assert.AreEqual(lstStocks.Count, dCorr.Count);

        }
    }
}
